<?
	session_start();	
	include('conn.php');		
	$id=$_REQUEST['id'];
	
	switch($id)
	{
		case '1':
			$qry1 = "select * from tran_field;";
			$qry = mysql_query($qry1);
			$data = array();			
			while($rows = mysql_fetch_array($qry))
			{		
				$data[] = array(					
					"inwarddate" => $rows['inwarddate'],					 
					"proposalno" => $rows['proposalno'],					 
					"policyno" => $rows['policyno'],					 
					"awbno" => $rows['awbno'],					 
					"filebarcode" => $rows['filebarcode'],					 
					"cartonbarcode" => $rows['cartonbarcode'],					 
					"districtid" => $rows['districtid'],					 
					"courierid" => $rows['courierid'],					 
					"remarks" => $rows['remarks'],					 					
				);
			}	
			echo json_encode($data);	
			break;
			
		case '2':
			$d = json_decode($_REQUEST["dataset"]);
			if($d->inwarddate == true) $d->inwarddate='y';
			else $d->inwarddate='n';
			if($d->proposalno == true) $d->proposalno='y';
			else $d->proposalno='n';
			if($d->policyno == true) $d->policyno='y';
			else $d->policyno='n';
			if($d->awbno == true) $d->awbno='y';
			else $d->awbno='n';
			if($d->filebarcode == true) $d->filebarcode='y';
			else $d->filebarcode='n';
			if($d->cartonbarcode == true) $d->cartonbarcode='y';
			else $d->cartonbarcode='n';
			if($d->districtid == true) $d->districtid='y';
			else $d->districtid='n';
			if($d->courierid == true) $d->courierid='y';
			else $d->courierid='n';
			if($d->remarks == true) $d->remarks='y';
			else $d->remarks='n';
			$qry = "update tran_field set 
					inwarddate='$d->inwarddate', proposalno='$d->proposalno', policyno='$d->policyno', awbno='$d->awbno', filebarcode='$d->filebarcode',cartonbarcode='$d->cartonbarcode',districtid='$d->districtid',courierid='$d->courierid', remarks='$d->remarks'
					where id='1'";
					$res = mysql_query($qry);
					echo $qry." - ".$res;
			break;
	}
	
	
?>